<?php
$sql_blog = "select * from inancm_blog where blog_id = '".$id."'";
$data_blog = $inancm->select_db($sql_blog);
?>

<div class="row">
  <div class="col-md-6" style="padding-right:40px;">
  <form class="form-horizontal" action="" method="post"  enctype="multipart/form-data">
	<fieldset>
        <legend>Edit Blog</legend>
        
        <div class="form-group">
           <label for="catid" class="col-sm-4 control-label">Category :</label>
           <div class="col-sm-8">
            	<?php
				$sql_category = "select * from inancm_category order by cat_id";
				$data_category = $inancm->select_db($sql_category);
				
				if (!isset($catid)){ $catid = 1; }			
				?>   
                <select id="form-s-s" name="catid" class="form-control">
                	<?php foreach($data_category as $val) { 	
						?>				
						<option value="<?=$val['cat_id']?>"
                         <?php if ($val['cat_id'] == $data_blog[0]['cat_id']) { echo "selected"; } ?> >
                        	<?=$val['cat_name']?>
                       	</option>
					<?php
                    }
					?>       
                </select>
           </div>
        </div>
        
        
        
        <div class="form-group">
           <label class="col-sm-4 control-label" for="">Image :</label>
           <div class="col-sm-8">
            	<input name="file" type="file">
                <span class="help-block" style="color:#F30;">437 x 126</span>
           </div>
        </div>
        
        <div class="form-group">
            <label class="col-sm-4 control-label" for="">Title :</label>
            <div class="col-sm-8">
            	<input type="text" name="btitle" placeholder="Title" class="form-control" value="<?=$data_blog[0]['blog_title']?>" required>
            </div>
        </div>
       
        <div class="form-group">
            <label class="col-sm-4 control-label" for="">Tag :</label>
            <div class="col-sm-8">
            	<input type="text" name="btag" placeholder="Tag" class="form-control" value="<?=$data_blog[0]['blog_tag']?>" required>
            </div>
        </div>        
       
       <div class="form-group">
            <label class="col-sm-4 control-label" for="">Post by :</label>
            <div class="col-sm-8">
            	<input type="text" name="bpost" placeholder="Post by" class="form-control" value="<?=$data_blog[0]['blog_post']?>" required>
            </div>
       </div>      
       
       <div class="form-group">
            <label class="col-sm-4 control-label" for="">Description :</label>
            <div class="col-sm-8">
            	<textarea type="text" name="bdes" placeholder="Description" class="form-control"><?=$data_blog[0]['blog_des']?></textarea>
            </div>
       </div>  
       
       <div class="form-group">
            <label class="col-sm-4 control-label" for="">Detail :</label>
            <div class="col-sm-8">
            	<textarea type="text" name="bdetail" placeholder="Detial" class="form-control"><?=$data_blog[0]['blog_detail']?></textarea>
            </div>
       </div>  
    </fieldset>
    <div class="form-group">
        <div class="col-sm-offset-6 col-sm-10">
            <input type="hidden" name="thisact" value="editsave">
            <input type="hidden" name="id" value="<?=$id?>">    
            <input type="hidden" name="oldtype" value="<?=$data_blog[0]['cat_id'];?>">
            <input type="hidden" name="oldimage" value="<?=$data_blog[0]['blog_image'];?>">
            <button class="btn btn-primary" type="submit">Save</button>
            <button class="btn btn-default" type="button" onClick="reloadPage();">Cancel</button>
        </div>
    </div>
  </form>
  
  </div>
  
  <div class="col-md-6" style="border-left:1px solid #DDD; padding-left:40px;">
  	<form class="well" style="border:#CCC 1px dashed; box-shadow:none;">
	<fieldset>
        <legend>Blog's image</legend>
        <div class="col-md-6">        	
            <img src="<?=$upload_dir;?><?=$data_blog[0]['blog_image'];?>" class="thumbnail">
        </div>
    </fieldset>
    </form>
  </div>
</div>